namespace Pyramid.Utility
{
	using System;
	using System.Collections.Generic;
	using System.Linq;

	/// <summary>
	/// A set of utility methods for parameter validation.
	/// </summary>
	public static class Validate
	{
		/// <summary>
		/// Checks that the specified value is greater than zero.
		/// </summary>
		/// <param name="value">
		/// An integer value to validate.
		/// </param>
		/// <param name="parameterName">
		/// The name of the parameter being validated.
		/// </param>
		/// <exception cref="System.ArgumentOutOfRangeException">
		/// <paramref name="value"/> is less than or equal to zero.
		/// </exception>
		public static void IsGreaterThanZero(int value, string parameterName)
		{
			if (value <= 0)
			{
				throw new ArgumentOutOfRangeException(parameterName);
			}
		}

		public static void IsLongEnough<T>(IEnumerable<T> value, int length, string parameterName)
		{
			if (value.Count() < length)
			{
				throw new ArgumentException("Collection is not large enough.", parameterName);
			}
		}

		public static void IsNotNull<T>(T value, string parameterName)
		{
			if (value == null)
			{
				throw new ArgumentNullException(parameterName);
			}
		}
	}
}
